package cn.thread;

public class YieldTest {
public static void main(String args[]){
    new Thread(()->{
        for(int i=0;i<100;i++){
            System.out.println("lambda..."+i);
        }
    }).start();
    for(int i=0;i<100;i++){
        if(i%10==0)
            Thread.yield();
        System.out.println("main..."+i);
    }
}
}
class YieldTest001 implements Runnable{
    public static void main(String args[]){
        YieldTest001 y=new YieldTest001();
        new Thread(y,"a").start();
        new Thread(y,"b").start();
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"-->"+"start");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"-->"+"end");
    }
}
